package charpter11.lynx;

import java.util.LinkedList;
import java.util.Queue;

public class TwentySeven {
	private static class Command {
		private String value;

		public Command(String valueOf) {
			value = valueOf;
		}

		public void operation() {
			System.out.println(value);
		}
	}

	private static class Test {
		private Queue<Command> queue = new LinkedList<TwentySeven.Command>();

		public Queue<Command> add(Command command){
			queue.offer(command);
			return queue;
		}
	}
	
	private static void consume(Queue<Command> queue){
		Command command;
		while ((command = queue.poll()) != null) {
			command.operation();
		}
	}
	
	public static void main(String[] args) {
		Test test = new TwentySeven.Test();
		Queue<Command> queue = null;
		for(int i = 0; i < 100; i++){
			queue = test.add(new Command(String.valueOf(i)));
		}
		
		consume(queue);
	}
}
